package com.security.user.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author yanggld
 * @Date 2020/3/9-12:16
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class UserInfo {
    private Long id;
    private String username;
    private String password;
    private String permissions;

    public boolean hasPermission(String method) {
        boolean result = false;
        if (StringUtils.equalsIgnoreCase("get",method)) {
            result = StringUtils.contains(permissions,"r");
        } else {
            result = StringUtils.contains(permissions,"w");
        }
        return result;
    }
}
